package com.alibaba.cloud.demo.controller;

import com.alibaba.cloud.demo.service.StreamProductService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.crypto.MacSpi;
import java.util.HashMap;
import java.util.Map;

@RestController
public class IndexController {



    @Autowired
    private StreamProductService streamProductService;
    @GetMapping("port")
    public Integer port1(JSONObject jsonObject) {
        return 11;
    }


    @GetMapping("send")
    public void send(String name) {
        JSONObject o = new JSONObject();
        o.put("name", name);
        Map<String, Object> map = new HashMap<>();
        map.put("token", "token");
        map.put("name", o);
        streamProductService.publish(o, map);

    }



    @GetMapping("send2")
    public void send2(String name, String token) {
        JSONObject o = new JSONObject();
        o.put("name", name);
        Map<String, Object> map = new HashMap<>();
        map.put("token", token);
        map.put("name", o);

        streamProductService.publish1(o, map);

    }


}
